package com.nercel.dsj.gksales.api.controller;


import com.nercel.dsj.gksales.model.ListResult;
import com.nercel.dsj.gksales.model.QueryParams;
import com.nercel.dsj.gksales.model.dto.PaymentResultDTO;
import com.nercel.dsj.gksales.service.PaymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
//@Api(tags="支付明细管理")
public class PaymentApiController extends BaseApiController{
	
	@Autowired
	private PaymentService paymentService;

	/*
        <if test='params.userId != null'>
            and p.user_id = #{params.userId}

        <if test='params.orderNumber != null and params.orderNumber != ""'>
            and (p.order_number like concat(#{params.orderNumber},'%'))
        </if>
        <if test='params.payedNumber != null and params.payedNumber != ""'>
            and (p.payed_number like concat(#{params.payedNumber},'%'))
        </if>,			//支付宝

	WEI_XIN
	 */

	@ApiOperation(value = "付款明细查询接口")
    @RequestMapping(value="/api/v1/payments", method= RequestMethod.GET)
    public ListResult<PaymentResultDTO> listPayments(
			@ApiParam(hidden = true) QueryParams queryParams,
			@ApiParam(value = "页码") @RequestParam(required = false) Integer page,
			@ApiParam(value = "单页数量") @RequestParam(required = false) Integer pageSize,
			@ApiParam(value = "备注关键词") @RequestParam(required = false) String keyword,
			@ApiParam(value = "支付类型(ALI_PAY/WEI_XIN)") @RequestParam(required = false) String type,
			@ApiParam(value = "支付额度(分)") @RequestParam(required = false) Integer amount,
			@ApiParam(value = "支付金额（起）") @RequestParam(required = false) Integer amountBegin,
			@ApiParam(value = "支付金额（止）") @RequestParam(required = false) Integer amountEnd,
			@ApiParam(value = "服务类型(GK_AGENT_RECHARGE/GK_VIP)") @RequestParam(required = false) String serviceType,
			@ApiParam(value = "支付成功(1/0)") @RequestParam(required = false, defaultValue = "1") Integer successful,
			@ApiParam(value = "起始时间") @RequestParam(required = false) String payedTimeBegin,
			@ApiParam(value = "截止时间") @RequestParam(required = false) String payedTimeEnd,
			@ApiParam(value = "定单号") @RequestParam(required = false) String orderNumber,
			@ApiParam(value = "支付编号") @RequestParam(required = false) String payedNumber,
			@ApiParam(value = "手机号") @RequestParam(required = false) String phone,
			@ApiParam(value = "用户ID") @RequestParam(required = false) Integer userId) {
		queryParams.put("keyword", keyword);
		queryParams.put("type", type);
		queryParams.put("amount", amount);
		queryParams.put("amountBegin", amountBegin);
		queryParams.put("amountEnd", amountEnd);
		queryParams.put("serviceType", serviceType);
		queryParams.put("successful", successful);
		queryParams.put("payedTimeBegin", payedTimeBegin);
		queryParams.put("payedTimeEnd", payedTimeEnd);
		queryParams.put("orderNumber", orderNumber);
		queryParams.put("payedNumber", payedNumber);
		queryParams.put("phone", phone);
		queryParams.put("userId", userId);
		return paymentService.listWithPaging(queryParams);
    }


    
	    
}
